//上传图片
"use strict";
let upload = document.getElementById("upload");
upload.addEventListener('click',function(){
    $("#pic_file").click();
});
let pic_file = document.getElementById("pic_file");
pic_file.addEventListener('change',function(){
    let file = pic_file.files[0];
    let formData = new FormData();
    formData.append('file',file);
    AjaxUpload('upload.php','POST',formData,function(data){
        const res = JSON.parse(data);
        if(res.status == 1){
            document.getElementById("pic_show").style.display = 'block';
            document.getElementById("pic_show").setAttribute('src','/lh_upload'+res.path);
            document.querySelector("[name='pic']").value = res.path;
            document.getElementById('shuoming').innerHTML = res.msg;
        }else{
            alert('文件上传失败');
        }
    });
});


//上传图片说明
let info = document.getElementById("info");
[...info.textContent].reduce((pre,cur,index) => {
    pre == index && (info.innerHTML = "");
    let span = document.createElement("span");
    span.textContent = cur;
    info.appendChild(span);
    span.addEventListener('mouseover',function(){
        this.classList.add('changeColor');
    });
    span.addEventListener('animationend',function(){
        this.classList.remove("changeColor");
    });
},0);


